package com.jinke.api.runner;

import com.jinke.api.config.MessageConf;
import com.jinke.api.modules.third.easypost.conf.AccountIdConf;
import com.jinke.api.modules.third.easypost.util.EasypostUtil;
import com.jinke.api.modules.third.ezeeship.util.EzeeShipUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class MyStartupRunner implements CommandLineRunner, ApplicationRunner {

    @Autowired
    private AccountIdConf accountIdConf;
    @Autowired
    private MessageConf messageConf;
    @Override
    public void run(String... args) throws Exception {
        // 这里写入启动时需要执行的逻辑
//        log.info("== init carryship token start");
//        CarryshipUtil.getetToken();
//        log.info("== init carryship token end");

        EasypostUtil.accountIds = accountIdConf.getAccountIds();
        Map<String, String> messages = messageConf.getMessages();
        messages.put("余额不足","Service in Maintenance now, Please Contact Support");
        messages.put("Account balance","Service in Maintenance, Please Contact Support");
        EzeeShipUtil.messages = messages;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 这里写入启动时需要执行的逻辑
        //  System.out.println("ApplicationRunner 执行");
    }
}
